//
//  ComplainViewController.m
//  SXH
//
//  Created by Jack on 15/10/21.
//  Copyright © 2015年 lyss. All rights reserved.
//

#import "ComplainViewController.h"
#import "CommonService.h"

@interface ComplainViewController ()
@property (weak, nonatomic) IBOutlet UITextView *content;
@property (weak, nonatomic) IBOutlet UITextField *phone;

@end

@implementation ComplainViewController
@synthesize parkEntity;
@synthesize content;
@synthesize phone;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)postComplain:(id)sender {
    [self.view endEditing:YES];
    
    [super showLoadingView:YES];
    
    CommonService *service = [[CommonService alloc] init];
    NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:
                           parkEntity.ID, @"parkid",
                           parkEntity.title, @"parkname",
                           content.text, @"content",
                           phone.text, @"phone",nil];
    
    [service getNetWorkData:param
                       Path:PARK_COMPLAIN
                  Successed:^(id entity) {
                      NSDictionary *dic = (NSDictionary *)entity;
                      
                      NSString *code = [dic valueForKey:@"code"];
                      if([code intValue]==0){
                          ALERT_ERR_MSG(@"提交成功!");
                      }else{
                          ALERT_ERR_MSG(@"提交失败!");
                      }
                      [super showLoadingView:NO];
                  } Failed:^(NSInteger errorCode, NSString *message) {
                      [super showLoadingView:NO];
                      DebugLog(@"%@", message);
                  }];
}

//按键盘完成时取消焦点：

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder]; //取消焦点／隐藏键盘
    
    return YES;
    
}
@end
